/**
* Plugin which uses the Google AJAX Feed API for creating feed content
* @author: M. Alsup (malsup at gmail dot com)
* @version: 1.0.2 (5/11/2007)
* Documentation and examples at: http://www.malsup.com/jquery/gfeed/
* Free beer and free speech. Enjoy!
*/
(function($) {
	if (!window.google) {
		alert('You must include the Google AJAX Feed API script');
		return;
	}
	if (!google.feeds) google.load("feeds", "1");
	$.fn.hFeed = function(options) {
		var opts = jQuery.extend({
			target: this,
			max: 5 // max number of items per feed
		}, options || {});
		function pubDate(dateStr){
			var ent = dateStr.split(/\s/g);
			return ent[1]+' '+ent[2]+' '+ent[3]+ ' ' +ent[4];
		}
		function resLoaded(result){
			//alert(JSON.stringify(result));
			$(opts.target).each(function() {
				var fillEl = $(this);
				var entStr = '<marquee>';
				for (var i = 0; i < result.feed.entries.length; i++) {
					var entry = result.feed.entries[i];
					entStr = entStr + pubDate(entry.publishedDate) + '&nbsp;<a href="'+entry.link+'" target="_blank">'+entry.title+'</a>&nbsp;&nbsp;&nbsp;&nbsp;';
				}
				entStr = entStr + '</marquee>';
				fillEl.html('');
				var mq = $(entStr).appendTo(fillEl);
				mq.attr('scrolldelay','3');
				mq.attr('scrollamount','2');
				mq.hover(function(){
					mq.trigger('stop');
				},function(){
					mq.trigger('start');
				});
			});
		}
		var g = new google.feeds.Feed(opts.url);
		g.setNumEntries(opts.max);
		g.load(resLoaded);
		setTimeout("g.load(resLoaded)",600000);
		return this;
	};
})(jQuery);